<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
    <title>数据追踪</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/lib/dataTables.bootstrap.css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/paginate.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/table.css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/qulitity.css" type="text/css" type="text/css">
    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <script>

    </script>
</head>
<body>
<div class="wrap">
    <div class="page-header">
        <ul class="page_nav">
            <li class="first cur">医卫士云平台&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;</li>
            <li class="cur">系统管理&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;</li>
            <li>数据追踪</li>
        </ul>
    </div>
    <div class="form">
        <label>仪器SN号:</label>
        <input id="message" type="text" class="SN" placeholder="仪器SN号">
        <label>消息状态:</label>
        <select id="status" name="status" >
            <medi:configOpt name="messageStatus"/>
        </select>
        <label>&nbsp;&nbsp;&nbsp;&nbsp;接收状态:</label>
        <select id="ack" name="ack" >
            <medi:configOpt name="messageAckStatus"/>
        </select>
        <label>&nbsp;&nbsp;&nbsp;&nbsp;推送状态:</label>
        <select id="publish" name="publish" >
            <medi:configOpt name="messagePublishStatus"/>
        </select>
<%--            <label for="time" class="illtype" style="margin-left:29px;margin-right:20px;">时间</label>--%>
<%--            <div style="width:120px;display:inline-block;vertical-align:middle;margin-bottom:5px;">--%>
<%--                <div id="PrevTime" class="input-group date form_date" style="width: 100%"  data-date-format="yyyy-mm-dd" >--%>
<%--                    <input id="beginDate" type="text" class="lay-date" placeholder="  开始日期" readonly>--%>
<%--                </div>--%>
<%--            </div>--%>
<%--            ---%>
<%--            <div style="width:120px;display:inline-block;vertical-align:middle;margin-bottom:5px;">--%>
<%--                <div id="PrevTime" class="input-group date form_date" style="width: 100%"  data-date-format="yyyy-mm-dd" style="width:120px;display:inline-block">--%>
<%--                    <input id="endDate" type="text" class="lay-date" placeholder="  截止日期" readonly>--%>
<%--                </div>--%>
<%--            </div>--%>

        <input id="query" type="button" value="搜索" class="search" onclick="refreshTable();">
        <span class="clear" onclick="cleanForm()">清除条件</span>
        <div></div>
    </div>
    <div id="tablepart">
        <table id="example" class="display" cellspacing="10" width="100%">
            <thead>
            <tr>
                <th><input id="all_id" type="checkbox"></th>
                <th>消息内容</th>
                <th>消息状态</th>
                <th>重试次数</th>
                <th>接收状态</th>
                <th>推送状态</th>
                <th>创建时间</th>
                <th>更新时间</th>
            </tr>
            </thead>
        </table>
    </div>
</div>
<script>
    var table;

    function initTable() {
        table = $('#example').DataTable({
            "dom": "<'row'<'col-xs-2'l><'#mytool.col-xs-10'><'col-xs-6'f>r>" +
                "t" +
                "<'row'<'col-xs-6'i><'col-xs-6'p>>",
            "bFilter": false,//去掉搜索框
            "bAutoWidth": true, //自适应宽度
            "sPaginationType": "full_numbers",
            "ordering": false,//是否允许Datatables开启排序
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": "${URL_MESSAGE_LOG_SEARCH}",
            "sAjaxDataProp": "dataList",//查询后，返回的集合
            "fnServerData": function (sSource, aoData, fnCallback) {  //查询条件
                aoData.push(
                    {"name": "message", "value": $("#message").val()},
                    {"name": "status", "value": $("#status").val()},
                    {"name": "ack", "value": $("#ack").val()},
                    {"name": "publish", "value": $("#publish").val()}
                );
                $.ajax({
                    "dataType": 'json',
                    "url": sSource,
                    "type": 'post',
                    "data": aoData,
                    "success": fnCallback
                });

            },

            "aoColumns": [{
                "targets": -1,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    $(nTd).html('' +
                        '&nbsp;&nbsp;<input name="id" value="' + oData.id + '" type="checkbox" onClick="isCheckedAll()">' +
                        '');
                }
            }, {
                "mDataProp": "message"
            },
            {
                "targets": 2,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    if (sData.status == 0) {
                        $(nTd).html("发送中");
                    } else if (sData.status == 1) {
                        $(nTd).html("成功");
                    } else {
                        $(nTd).html("失败");
                    }
                }
            },
            {
                "mDataProp": "tryCount"
            },
            {
                "targets": 4,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    if (sData.ack == "0") {
                        $(nTd).html("未接收");
                    } else if (sData.ack == "1") {
                        $(nTd).html("已接收");
                    } else {
                        $(nTd).html("");
                    }
                }
            },
            {
                "targets": 5,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    if (sData.publish == "0") {
                        $(nTd).html("未推送");
                    } else if (sData.publish == "1") {
                        $(nTd).html("已推送");
                    } else {
                        $(nTd).html("");
                    }
                }
            },
            {
                "mDataProp": "createTime"
            },
            {
                "mDataProp": "updateTime"
            }],
            "createdRow": function (row, data, index) {
                $('td', row).eq(0).addClass('border_left');
                $('td', row).eq(7).addClass('border_right');
            },
            "oLanguage": {//插件的汉化
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "当前显示 _START_ 到 _END_条 ,共 _TOTAL_ 条记录",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上一页",
                    "sNext": "下一页",
                    "sLast": "末页"
                },
                "sZeroRecords": "没有检索到数据",
                "sProcessing": "<img src='' />",
                "sSearch": "搜索"
            },
            "initComplete": function () {
            }
        });
    }

    $(document).ready(function () {
        initTable();
        $('#example tr th').eq(0).addClass('border_left');
        $('#example tr th').eq(7).addClass('border_right');
        $('#example tbody tr td').addClass('active');
        $('#example tr td').eq(7).addClass('border_right');
        $('#example_paginate').parent().addClass('pagewidth');
        $('#example_info').parent().addClass('showPage');
        $('#example_length').parent().addClass('pageNow');
    });

</script>
</body>
</html>